<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWritesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('writes', function (Blueprint $table) {
            $table->id();
            $table->integer('category_id')->comment('所属分类');
            $table->integer('user_id')->comment('作者');
            $table->string('title')->comment('文章题目');
            $table->string('cover')->nullable()->comment('显示图片');
            $table->tinyInteger('is_locked')->default(0)->comment('删除 1禁用0使用');
            $table->string('subs')->comment('文章内容');
            $table->integer('view_num')->default(0)->comment('浏览数量');
            $table->tinyInteger('is_on')->default(0)->comment('上热门0不热门1热门');
            $table->json('labs')->nullable();
            $table->timestamps();
            $table->index('category_id');
            $table->index('title');
            $table->index('subs');
            $table->index('is_on');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('writes');
    }
}
